package Interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import java.util.Map;

public class UserLoginStateCheck extends AbstractInterceptor {


    @Override
    public String intercept(ActionInvocation actionInvocation) throws Exception {
        Map session = actionInvocation.getInvocationContext().getSession();
        if (session == null ||session.get("userid")==null|| session.get("userid").equals("")) {
            //注意userid为""表示用户主动退出
            return "login";
        }
        return actionInvocation.invoke();
    }
}
